package com.biz.primus.ms.commodity.api;

import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.commodity.vo.GroupProductDetailVo;
import com.biz.primus.commodity.vo.GroupProductVo;
import com.biz.primus.commodity.vo.backend.GroupProductItemItemVo;
import com.biz.primus.commodity.vo.backend.GroupProductItemQueryVo;
import com.biz.primus.commodity.vo.backend.ProductVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.commodity.dao.po.Product;
import com.biz.primus.ms.commodity.service.backend.ExtendService;
import com.biz.primus.ms.commodity.service.frontend.GroupProductService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 组合商品服务端controller
 * @author wan
 */
@RestController
@RequestMapping("soa/groupProductController")
public class GroupProductApiController extends BaseApiController{

    private final GroupProductService groupProductService;
    private final ExtendService extendService;

    @Autowired
    public GroupProductApiController(GroupProductService groupProductService, ExtendService extendService){
        this.groupProductService = groupProductService;
        this.extendService = extendService;
    }

    /**
     * 查询-所有组合商品
     */
    @ApiOperation("组合商品-查询-所有组合商品")
    @PostMapping("findGroupProductList")
    public SpringPageVO<GroupProductItemItemVo> findGroupProductList(@RequestBody GroupProductItemQueryVo queryVo){
        SpringPageVO<GroupProductItemItemVo> groupProductList = groupProductService.findGroupProductList(queryVo);
        return groupProductList;
    }

    @ApiOperation("所有商品-查询")
    @PostMapping("findGroupProductSelectList")
    public List<ProductVo> findGroupProductSelectList(){
        List<ProductVo> list = groupProductService.findGroupProductSelectList();
        return list;
    }

    @ApiOperation("保存组合商品")
    @PostMapping("save")
    public void save(@RequestBody  GroupProductVo groupProductVo){
        groupProductService.save(groupProductVo);
    }

    @ApiOperation("删除组合商品")
    @GetMapping("del")
    public void del(@RequestParam("id") String id){
        groupProductService.del(id);
    }

    @ApiOperation("查询组合商品")
    @GetMapping("findGroupProductById")
    public GroupProductVo findGroupProductById(@RequestParam("id") String id){
        return groupProductService.findGroupProductById(id);
    }
}
